home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OInterfaces / SoundComponents.mod < prev    next >
Encoding:
Text File  |  1995-08-10  |  14.5 KB  |  327 lines  |  [TEXT/MPS ]

  1. (*
  2.      File:        SoundComponents.mod
  3.  
  4.      Contains:    Sound Components Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs.applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. *)
  19.  
  20. (*$TAGS-*)
  21. (*$CALLING PASCAL*)
  22. MODULE SoundComponents;
  23.  
  24. IMPORT SYSTEM, Types, Components, Sound;
  25.  
  26. (* $PUSH*)
  27. (* $ALIGN MAC68K*)
  28. (* $LibExport+*)
  29. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  30. (* constants*)
  31. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  32.  
  33. CONST
  34. (*sound component set/get info selectors*)
  35.     siVolume*                    = LONG("volu");
  36.     siHardwareVolume*            = LONG("hvol");
  37.     siSpeakerVolume*                = LONG("svol");
  38.     siHeadphoneVolume*            = LONG("pvol");
  39.     siHardwareVolumeSteps*        = LONG("hstp");
  40.     siHeadphoneVolumeSteps*        = LONG("hdst");
  41.     siHardwareMute*                = LONG("hmut");
  42.     siSpeakerMute*                = LONG("smut");
  43.     siHeadphoneMute*                = LONG("pmut");
  44.     siRateMultiplier*            = LONG("rmul");
  45.     siQuality*                    = LONG("qual");
  46. (*format types*)
  47.     kOffsetBinary*                = LONG("raw ");
  48.     kTwosComplement*                = LONG("twos");
  49.     kMACE3Compression*            = LONG("MAC3");
  50.     kMACE6Compression*            = LONG("MAC6");
  51.  
  52. (*quality flags*)
  53. (*use interpolation in rate conversion*)
  54.     kBestQuality*                = ASH(1,0);
  55.  
  56. (*useful bit masks*)
  57.     kInputMask*                    = $000000FF;                    (*masks off input bits*)
  58.     kOutputMask*                    = $0000FF00;                    (*masks off output bits*)
  59.     kOutputShift*                = 8;                            (*amount output bits are shifted*)
  60.     kActionMask*                    = $00FF0000;                    (*masks off action bits*)
  61.     kSoundComponentBits*            = $00FFFFFF;
  62.  
  63. (*SoundComponentPlaySourceBuffer action flags*)
  64.     kSourcePaused*                = ASH(1,0);
  65.     kPassThrough*                = ASH(1,16);
  66.     kNoSoundComponentChain*        = ASH(1,17);
  67. (*flags for OpenMixerSoundComponent*)
  68.     kNoMixing*                    = ASH(1,0);                (*don't mix source*)
  69.     kNoSampleRateConversion*        = ASH(1,1);                (*don't convert sample rate (i.e. 11 kHz -> 22 kHz)*)
  70.     kNoSampleSizeConversion*        = ASH(1,2);                (*don't convert sample size (i.e. 16 -> 8)*)
  71.     kNoSampleFormatConversion*    = ASH(1,3);                (*don't convert sample format (i.e. LONG("twos") -> LONG("raw "))*)
  72.     kNoChannelConversion*        = ASH(1,4);                (*don't convert stereo/mono*)
  73.     kNoDecompression*            = ASH(1,5);                (*don't decompress (i.e. LONG("MAC3") -> LONG("raw "))*)
  74.     kNoVolumeConversion*            = ASH(1,6);                (*don't apply volume*)
  75.     kNoRealtimeProcessing*        = ASH(1,7);                (*won't run at interrupt time*)
  76.  
  77. (*Audio Components.Component constants*)
  78. (*Values for whichChannel parameter*)
  79.     audioAllChannels*            = 0;                            (*All channels (usually interpreted as both left and right)*)
  80.     audioLeftChannel*            = 1;                            (*Left channel*)
  81.     audioRightChannel*            = 2;                            (*Right channel*)
  82. (*Values for mute parameter*)
  83.     audioUnmuted*                = 0;                            (*Device is unmuted*)
  84.     audioMuted*                    = 1;                            (*Device is muted*)
  85. (*Capabilities flags definitions*)
  86.     audioDoesMono*                = ASH(1,0);                (*Device supports mono output*)
  87.     audioDoesStereo*                = ASH(1,1);                (*Device supports stereo output*)
  88.     audioDoesIndependentChannels* = ASH(1,2);            (*Device supports independent software control of each channel*)
  89.  
  90. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  91. (* typedefs*)
  92. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  93. (*ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,*)
  94. (*with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375*)
  95.     
  96. TYPE
  97.     ShortFixed* = INTEGER;
  98.  
  99.     SoundComponentDataPtr* = POINTER TO SoundComponentData;
  100.  
  101.     SoundComponentData* = RECORD
  102.         flags*:                    LONGINT;
  103.         format*:                    Types.OSType;
  104.         numChannels*:            INTEGER;
  105.         sampleSize*:                INTEGER;
  106.         sampleRate*:                Sound.UnsignedFixed;
  107.         sampleCount*:            LONGINT;
  108.         buffer*:                    SYSTEM.PTR (*ΔΔ POINTER TO Types.Byte*);
  109.         reserved*:                LONGINT;
  110.     END;
  111.  
  112.     SoundParamBlockPtr* = POINTER TO SoundParamBlock;
  113.  
  114.     SoundParamProcPtr* = (*ΔΔ Types.ProcPtr;*) PROCEDURE (VAR pb: SoundParamBlockPtr): BOOLEAN;
  115.     SoundParamUPP* = Types.UniversalProcPtr;
  116.  
  117.     SoundParamBlock* = RECORD
  118.         recordSize*:                LONGINT;                                (*size of this record in bytes*)
  119.         desc*:                    SoundComponentData;                        (*description of sound buffer*)
  120.         rateMultiplier*:            Sound.UnsignedFixed;                            (*rate multiplier to apply to sound*)
  121.         leftVolume*:                INTEGER;                                (*volumes to apply to sound*)
  122.         rightVolume*:            INTEGER;
  123.         quality*:                LONGINT;                                (*quality to apply to sound*)
  124.         filter*:                    Components.ComponentInstance;                        (*filter to apply to sound*)
  125.         moreRtn*:                SoundParamUPP;                            (*routine to call to get more data*)
  126.         completionRtn*:            SoundParamUPP;                            (*routine to call when buffer is complete*)
  127.         refCon*:                    LONGINT;                                (*user refcon*)
  128.         result*:                    INTEGER;                                (*result*)
  129.     END;
  130.  
  131.     SoundSource* = Types.Ptr;
  132.  
  133.     AudioInfo* = RECORD
  134.         capabilitiesFlags*:        LONGINT;                                (*Describes device capabilities*)
  135.         reserved*:                LONGINT;                                (*Reserved by Apple*)
  136.         numVolumeSteps*:            INTEGER;                                (*Number of significant increments between min and max volume*)
  137.     END;
  138.  
  139.     AudioInfoPtr* = POINTER TO AudioInfo;
  140.  
  141. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  142. (* functions for sound components*)
  143. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  144. (*Sound Components.Component dispatch selectors*)
  145.  
  146. CONST
  147. (*these calls cannot be delegated*)
  148.     kSoundComponentInitOutputDeviceSelect* = 1;
  149.     kSoundComponentSetSourceSelect* = 2;
  150.     kSoundComponentGetSourceSelect* = 3;
  151.     kSoundComponentGetSourceDataSelect* = 4;
  152.     kSoundComponentSetOutputSelect* = 5;
  153.     kDelegatedSoundComponentSelectors* = $0100;                    (*first selector that can be delegated up the chain*)
  154. (*these calls can be delegated and have own range*)
  155.     kSoundComponentAddSourceSelect* = kDelegatedSoundComponentSelectors + 1;
  156.     kSoundComponentRemoveSourceSelect* = kDelegatedSoundComponentSelectors + 2;
  157.     kSoundComponentGetInfoSelect* = kDelegatedSoundComponentSelectors + 3;
  158.     kSoundComponentSetInfoSelect* = kDelegatedSoundComponentSelectors + 4;
  159.     kSoundComponentStartSourceSelect* = kDelegatedSoundComponentSelectors + 5;
  160.     kSoundComponentStopSourceSelect* = kDelegatedSoundComponentSelectors + 6;
  161.     kSoundComponentPauseSourceSelect* = kDelegatedSoundComponentSelectors + 7;
  162.     kSoundComponentPlaySourceBufferSelect* = kDelegatedSoundComponentSelectors + 8;
  163.  
  164. (*Audio Components.Component selectors*)
  165.     kAudioGetVolumeSelect*        = 0;
  166.     kAudioSetVolumeSelect*        = 1;
  167.     kAudioGetMuteSelect*            = 2;
  168.     kAudioSetMuteSelect*            = 3;
  169.     kAudioSetToDefaultsSelect*    = 4;
  170.     kAudioGetInfoSelect*            = 5;
  171.     kAudioGetBassSelect*            = 6;
  172.     kAudioSetBassSelect*            = 7;
  173.     kAudioGetTrebleSelect*        = 8;
  174.     kAudioSetTrebleSelect*        = 9;
  175.     kAudioGetOutputDeviceSelect*    = 10;
  176.     kAudioMuteOnEventSelect*        = 129;
  177.  
  178. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  179. (* Sound Manager 3.0 utilities*)
  180.  
  181. PROCEDURE OpenMixerSoundComponent*(outputDescription: SoundComponentDataPtr; outputFlags: LONGINT; VAR mixerComponent: Components.ComponentInstance): Types.OSErr;
  182.     (*$IF NOT GENERATINGCFM*)
  183.     INLINE PASCAL $203C, $0614, $0018, $A800;
  184.     (*$END*)
  185. PROCEDURE CloseMixerSoundComponent*(ci: Components.ComponentInstance): Types.OSErr;
  186.     (*$IF NOT GENERATINGCFM*)
  187.     INLINE PASCAL $203C, $0218, $0018, $A800;
  188.     (*$END*)
  189. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  190. (* basic sound component functions*)
  191. PROCEDURE SoundComponentInitOutputDevice*(ti: Components.ComponentInstance; actions: LONGINT): Components.ComponentResult;
  192.     (*$IF NOT GENERATINGCFM*)
  193.     INLINE PASCAL $2F3C, 4, 1, $7000, $A82A;
  194.     (*$END*)
  195. PROCEDURE SoundComponentSetSource*(ti: Components.ComponentInstance; sourceID: SoundSource; source: Components.ComponentInstance): Components.ComponentResult;
  196.     (*$IF NOT GENERATINGCFM*)
  197.     INLINE PASCAL $2F3C, 8, 2, $7000, $A82A;
  198.     (*$END*)
  199. PROCEDURE SoundComponentGetSource*(ti: Components.ComponentInstance; sourceID: SoundSource; VAR source: Components.ComponentInstance): Components.ComponentResult;
  200.     (*$IF NOT GENERATINGCFM*)
  201.     INLINE PASCAL $2F3C, 8, 3, $7000, $A82A;
  202.     (*$END*)
  203. PROCEDURE SoundComponentGetSourceData*(ti: Components.ComponentInstance; VAR sourceData: SoundComponentDataPtr): Components.ComponentResult;
  204.     (*$IF NOT GENERATINGCFM*)
  205.     INLINE PASCAL $2F3C, 4, 4, $7000, $A82A;
  206.     (*$END*)
  207. PROCEDURE SoundComponentSetOutput*(ti: Components.ComponentInstance; requested: SoundComponentDataPtr; VAR actual: SoundComponentDataPtr): Components.ComponentResult;
  208.     (*$IF NOT GENERATINGCFM*)
  209.     INLINE PASCAL $2F3C, 8, 5, $7000, $A82A;
  210.     (*$END*)
  211. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  212. (* junction methods for the mixer, must be called at non-interrupt level*)
  213. PROCEDURE SoundComponentAddSource*(ti: Components.ComponentInstance; VAR sourceID: SoundSource): Components.ComponentResult;
  214.     (*$IF NOT GENERATINGCFM*)
  215.     INLINE PASCAL $2F3C, 4, $0101, $7000, $A82A;
  216.     (*$END*)
  217. PROCEDURE SoundComponentRemoveSource*(ti: Components.ComponentInstance; sourceID: SoundSource): Components.ComponentResult;
  218.     (*$IF NOT GENERATINGCFM*)
  219.     INLINE PASCAL $2F3C, 4, $0102, $7000, $A82A;
  220.     (*$END*)
  221. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  222. (* info methods*)
  223. PROCEDURE SoundComponentGetInfo*(ti: Components.ComponentInstance; sourceID: SoundSource; selector: Types.OSType; infoPtr: (*ΔΔUNIVΔΔ*) Types.Ptr): Components.ComponentResult;
  224.     (*$IF NOT GENERATINGCFM*)
  225.     INLINE PASCAL $2F3C, 12, $0103, $7000, $A82A;
  226.     (*$END*)
  227. PROCEDURE SoundComponentSetInfo*(ti: Components.ComponentInstance; sourceID: SoundSource; selector: Types.OSType; infoPtr: (*ΔΔUNIVΔΔ*) Types.Ptr): Components.ComponentResult;
  228.     (*$IF NOT GENERATINGCFM*)
  229.     INLINE PASCAL $2F3C, 12, $0104, $7000, $A82A;
  230.     (*$END*)
  231. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  232. (* control methods*)
  233. PROCEDURE SoundComponentStartSource*(ti: Components.ComponentInstance; count: INTEGER; VAR sources: SoundSource): Components.ComponentResult;
  234.     (*$IF NOT GENERATINGCFM*)
  235.     INLINE PASCAL $2F3C, 6, $0105, $7000, $A82A;
  236.     (*$END*)
  237. PROCEDURE SoundComponentStopSource*(ti: Components.ComponentInstance; count: INTEGER; VAR sources: SoundSource): Components.ComponentResult;
  238.     (*$IF NOT GENERATINGCFM*)
  239.     INLINE PASCAL $2F3C, 6, $0106, $7000, $A82A;
  240.     (*$END*)
  241. PROCEDURE SoundComponentPauseSource*(ti: Components.ComponentInstance; count: INTEGER; VAR sources: SoundSource): Components.ComponentResult;
  242.     (*$IF NOT GENERATINGCFM*)
  243.     INLINE PASCAL $2F3C, 6, $0107, $7000, $A82A;
  244.     (*$END*)
  245. PROCEDURE SoundComponentPlaySourceBuffer*(ti: Components.ComponentInstance; sourceID: SoundSource; pb: SoundParamBlockPtr; actions: LONGINT): Components.ComponentResult;
  246.     (*$IF NOT GENERATINGCFM*)
  247.     INLINE PASCAL $2F3C, 12, $0108, $7000, $A82A;
  248.     (*$END*)
  249. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  250. (* interface for Audio Components*)
  251. (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
  252. (*Volume is described as a value between 0 and 1, with 0 indicating minimum
  253.   volume and 1 indicating maximum volume; if the device doesn't support
  254.   software control of volume, then a value of unimpErr is returned, indicating
  255.   that these functions are not supported by the device*)
  256. PROCEDURE AudioGetVolume*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR volume: ShortFixed): Components.ComponentResult;
  257.     (*$IF NOT GENERATINGCFM*)
  258.     INLINE PASCAL $2F3C, 6, 0, $7000, $A82A;
  259.     (*$END*)
  260. PROCEDURE AudioSetVolume*(ac: Components.ComponentInstance; whichChannel: INTEGER; volume: ShortFixed): Components.ComponentResult;
  261.     (*$IF NOT GENERATINGCFM*)
  262.     INLINE PASCAL $2F3C, 4, 1, $7000, $A82A;
  263.     (*$END*)
  264. (*If the device doesn't support software control of mute, then a value of unimpErr is*)
  265. (*returned, indicating that these functions are not supported by the device*)
  266. PROCEDURE AudioGetMute*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR mute: INTEGER): Components.ComponentResult;
  267.     (*$IF NOT GENERATINGCFM*)
  268.     INLINE PASCAL $2F3C, 6, 2, $7000, $A82A;
  269.     (*$END*)
  270. PROCEDURE AudioSetMute*(ac: Components.ComponentInstance; whichChannel: INTEGER; mute: INTEGER): Components.ComponentResult;
  271.     (*$IF NOT GENERATINGCFM*)
  272.     INLINE PASCAL $2F3C, 4, 3, $7000, $A82A;
  273.     (*$END*)
  274. (*AudioSetToDefaults causes the associated device to reset its volume and mute values*)
  275. (*(and perhaps other characteristics, e.g. attenuation) to "factory default" settings*)
  276. PROCEDURE AudioSetToDefaults*(ac: Components.ComponentInstance): Components.ComponentResult;
  277.     (*$IF NOT GENERATINGCFM*)
  278.     INLINE PASCAL $2F3C, 0, 4, $7000, $A82A;
  279.     (*$END*)
  280. (*This routine is required; it must be implemented by all audio components*)
  281. PROCEDURE AudioGetInfo*(ac: Components.ComponentInstance; info: AudioInfoPtr): Components.ComponentResult;
  282.     (*$IF NOT GENERATINGCFM*)
  283.     INLINE PASCAL $2F3C, 4, 5, $7000, $A82A;
  284.     (*$END*)
  285. PROCEDURE AudioGetBass*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR bass: INTEGER): Components.ComponentResult;
  286.     (*$IF NOT GENERATINGCFM*)
  287.     INLINE PASCAL $2F3C, 6, 6, $7000, $A82A;
  288.     (*$END*)
  289. PROCEDURE AudioSetBass*(ac: Components.ComponentInstance; whichChannel: INTEGER; bass: INTEGER): Components.ComponentResult;
  290.     (*$IF NOT GENERATINGCFM*)
  291.     INLINE PASCAL $2F3C, 4, 7, $7000, $A82A;
  292.     (*$END*)
  293. PROCEDURE AudioGetTreble*(ac: Components.ComponentInstance; whichChannel: INTEGER; VAR Treble: INTEGER): Components.ComponentResult;
  294.     (*$IF NOT GENERATINGCFM*)
  295.     INLINE PASCAL $2F3C, 6, 8, $7000, $A82A;
  296.     (*$END*)
  297. PROCEDURE AudioSetTreble*(ac: Components.ComponentInstance; whichChannel: INTEGER; Treble: INTEGER): Components.ComponentResult;
  298.     (*$IF NOT GENERATINGCFM*)
  299.     INLINE PASCAL $2F3C, 4, 9, $7000, $A82A;
  300.     (*$END*)
  301. PROCEDURE AudioGetOutputDevice*(ac: Components.ComponentInstance; VAR outputDevice: Components.Component): Components.ComponentResult;
  302.     (*$IF NOT GENERATINGCFM*)
  303.     INLINE PASCAL $2F3C, 4, 10, $7000, $A82A;
  304.     (*$END*)
  305. (*This is routine is private to the AudioVision component.  It enables the watching of the mute key.*)
  306. PROCEDURE AudioMuteOnEvent*(ac: Components.ComponentInstance; muteOnEvent: INTEGER): Components.ComponentResult;
  307.     (*$IF NOT GENERATINGCFM*)
  308.     INLINE PASCAL $2F3C, 2, 129, $7000, $A82A;
  309.     (*$END*)
  310. CONST
  311.     uppSoundParamProcInfo* = $000000D0; (* PROCEDURE (4 byte param): 1 byte result; *)
  312.  
  313. PROCEDURE NewSoundParamProc*(userRoutine: SoundParamProcPtr): SoundParamUPP;
  314.     (*$IF NOT GENERATINGCFM *)
  315.     INLINE PASCAL $2E9F;
  316.     (*$END*)
  317.  
  318. PROCEDURE CallSoundParamProc*(VAR pb: SoundParamBlockPtr; userRoutine: SoundParamUPP): BOOLEAN;
  319.     (*$IF NOT GENERATINGCFM*)
  320.     INLINE PASCAL $205F, $4E90;
  321.     (*$END*)
  322.  
  323. (* $ALIGN RESET*)
  324. (* $POP*)
  325.  
  326.  END SoundComponents.
  327.